#!/usr/bin/env python
# -*- coding:utf-8 -*-
# 两数之和
# 给定一个整数数组 nums 和一个整数目标值 target，请你在该数组中找出 和为目标值 target  的那 两个 整数，并返回它们的数组下标。
#
# @Author    :zjk
# @Time      :2024/5/14 21:31
from typing import List


class Solution:

    def twoSum(self, nums: List[int], target: int) -> List[int]:
        dic = {}
        for i in range(len(nums)):
            if target - nums[i] in dic:
                return [i, dic[target - nums[i]]]
            dic[nums[i]] = i

if __name__ == '__main__':
    nums = [2, 7, 11, 15]
    target = 9
    solution = Solution()
    print(solution.twoSum(nums, target))

    nums = [3, 2, 4]
    target = 6
    print(solution.twoSum(nums, target))

    nums = [3, 3]
    target = 6
    print(solution.twoSum(nums, target))